package dao.impl;

import dao.BaseDao;
import dao.OrdersDao;
import pojo.Orders;

import java.util.List;

public class OrdersDaoImpl extends BaseDao implements OrdersDao {
    @Override
    public int addOrder(Orders order) {
        String sql="insert into orders values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
        return baseUpdate(sql,order.getOrd_no(),order.getBus_no(),order.getU_no(),
                order.getDel_no(),order.getOrd_dtime(),order.getArr_dtime(),
                order.getOrd_price(),order.getSt_time(),order.getSt_del(),
                order.getFi_del());
    }

    @Override
    public List<Orders> queryOrder() {
        String sql="select * from orders";
        return baseQuery(Orders.class,sql);
    }

    @Override
    public int finishOrder(Integer ord_no) {
        String sql="UPDATE orders set fi_del=1 WHERE ord_no=?;";
        return baseUpdate(sql,ord_no);
    }

    @Override
    public List<Orders> queryIncompleteOrder() {
        String sql="select * from orders where fi_del=0";
        return baseQuery(Orders.class,sql);
    }
}
